package com.iflyteck.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("login")
public class LoginController {

    @RequestMapping("/toLogin")
    public String toLogin() {
        System.out.println("==========跳转到登录页=============");
        return "login";
    }

    @RequestMapping("/loginSystem")
    public String doLogin(String username, String password, HttpSession session) {
        if ("admin".equals(username) && "admin".equals(password)) {
            System.out.println("合法用户！");
            session.setAttribute("username",username);
            return "redirect:/demo/result";
        } else {
            // 用户名密码输入有误
            return "redirect:/login/toLogin";
        }
    }

}
